#include <iostream>
#include <unistd.h>
#include <sys/types.h>
#include <vector>
using namespace std;

int main()
{
  vector<pid_t> allchild;
  for(int i = 0; i < 10; i++)
  {
    pid_t id = fork();
    if(id == 0)
    {
      cout << "子进程：pid: " << getpid() << ", ppid: " << getppid() <<endl;
      while(true)
      {
        sleep(5);
      }
    }
    else if(id > 0)
    {
      allchild.push_back(id);
    }
  }
  cout << "父进程：pid: " << getpid();
  for(auto& x : allchild)
  {
    cout << " " << x << " ";
  }
  cout << endl;
}



